import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:management/utils/custom_router.dart';
import 'package:management/views/mine/addDevice/add_device.dart';
import 'package:management/views/mine/setting/setting.dart';
import 'package:management/views/mine/speech_recognize.dart';
import 'package:management/views/mine/userInfo/user_info.dart';
import 'package:management/views/mine/versionInfo.dart';

///我的
class MinePage extends StatefulWidget {
  @override
  _MinePageState createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  static const String TAG = "SettingPage";

  @override
  void initState() {
    SystemChrome.setEnabledSystemUIOverlays([]);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "我的",
          style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25),
        ),
        centerTitle: true,
        backgroundColor: Colors.purple,
      ),
      body: SingleChildScrollView(
        child: _buildBody(),
      ),
    );
  }

  _buildBody() => Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        color: Colors.white,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            SizedBox(
              height: 10,
            ),
            Container(
              color: Colors.white,
              child: ListTile(
                leading: Icon(
                  Icons.person,
                  size: 35,
                ),
                title: Text(
                  "管理员信息",
                  style: TextStyle(
                    fontSize: 30,
                    color: Colors.black,
                  ),
                ),
                trailing: Icon(
                  Icons.chevron_right,
                  size: 35,
                ),
                onTap: () => //Navigator.of(context).pushNamed('/UserInfo'),
                    Navigator.push(context, SlideRoute(UserInfo())),
              ),
            ),
            Divider(
              height: 20,
              thickness: 20,
            ),
            ListTile(
              leading: Icon(
                Icons.add,
                size: 35,
              ),
              title: Text(
                "添加设备",
                style: TextStyle(
                  color: Colors.black,
                  fontSize: 30,
                ),
              ),
              trailing: Icon(
                Icons.chevron_right,
                size: 35,
              ),
              onTap: () {
                // Navigator.of(context).pushNamed('/AddDevice');
                Navigator.push(context, SlideRoute(AddDevice()));
              },
            ),
            Divider(
              height: 20,
              thickness: 20,
            ),
            ListTile(
              leading: Icon(
                Icons.keyboard_voice,
                size: 35,
              ),
              title: Text(
                "语音识别",
                style: TextStyle(fontSize: 30),
              ),
              trailing: Icon(
                Icons.chevron_right,
                size: 35,
              ),
              onTap: () async {
                // Navigator.of(context).pushNamed('/SpeechRecognize');
                Navigator.push(context, SlideRoute(SpeechRecognize()));
                // List<GateModel> allGates =
                //     await GateProvider.instance.getAllGate();
                //更新语音识别的词典由设备名称+/n 组成。e.g. "北门/n南门/n" 详见讯飞官方文档离线命令词识别
                //https://www.xfyun.cn/doc/asr/commandWord/Android-SDK.html
                // String data = "";
                // allGates.forEach((element) {
                //   data += "${element.deviceName}\n";
                // });
                // MyLog.w("data:$data");
                //跳转到AsrActivity
                // intentChannel
                //     .send(IntentModel("AsrActivity", data: data).toMap());
                // mscChannel.send("收不到消息吗？");
              },
            ),
            // Divider(),
            // MyClock(),
            // ListTile(
            //   leading: Icon(Icons.camera,size: 35,),
            //   title: Text(
            //     "可视对讲",
            //     style: TextStyle(fontSize: 30),
            //   ),
            //   trailing: Icon(
            //     Icons.chevron_right,
            //     size: 35,
            //   ),
            //   onTap: () {
            //     // Navigator.of(context).pushNamed('/VideoIntercom');
            //     // Navigator.pushNamed(context, "/Agora");
            //     // Navigator.pushNamed(context, "/IndexPage");
            //     // Navigator.push(context, SlideRoute(IndexPage()));
            //   },
            // ),
            Divider(
              height: 20,
              thickness: 20,
            ),
            ListTile(
              leading: Icon(
                Icons.info_outline_rounded,
                size: 35,
              ),
              trailing: Icon(
                Icons.chevron_right,
                size: 35,
              ),
              title: Text(
                "关于",
                style: TextStyle(fontSize: 30),
              ),
              onTap: () {
                // Navigator.pushNamed(context, '/VersionInfo');
                Navigator.push(context, SlideRoute(VersionInfo()));
              },
            ),
            Divider(),
            ListTile(
              leading: Icon(
                Icons.settings,
                size: 35,
              ),
              trailing: Icon(
                Icons.chevron_right,
                size: 35,
              ),
              title: Text(
                "设置",
                style: TextStyle(fontSize: 30),
              ),
              onTap: () {
                // Navigator.pushNamed(context, "/Setting");
                Navigator.push(context, SlideRoute(Setting()));
              },
            ),
            Expanded(
              child: Container(
                color: Color(0x1F000000),
              ),
            ),
          ],
        ),
      );
}
